package com.zsw.talk;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

public class Test {
	
	public static void main(String[] args) {
		try {
			Socket socket = new Socket("127.0.0.1", 8899);
			BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			PrintWriter pw = new PrintWriter(socket.getOutputStream(),true);
			pw.append("你好");
			pw.flush();
			while(true){
				char[] cc = new char[1024];
				reader.read(cc);
//				pw.append(new String(cc));
//				pw.flush();
				System.out.println(cc);
				pw.close();
				reader.close();
				socket.close();
			}
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
